package com.bjsxt;
//测试通配符
public class Test6 {
    public static void main(String[] args) {
        ShowMsg showMsg = new ShowMsg();
        Generic<Integer> generic = new Generic<>();
        generic.setFlag(20);
        showMsg.showFlag(generic);

        //Generic<Number> generic1 = new Generic<>();
        // 虽然Number是Inter的父类 ，也不可以用
        //要与public void showFlag(Generic<Integer> generic)中的
        //Integers类型相同
        //showMsg.showFlag(generic1);//报错
        Generic<Integer> generic1=new Generic<>();
        showMsg.showFlag(generic1);

        //改成通配符后
        ShowMsg showMsg1 = new ShowMsg();
        Generic<Number> generic2 = new Generic<>();
        generic2.setFlag(50);
        showMsg1.showFlag02(generic2);


        Generic<String> generic3 = new Generic<>();
        generic3.setFlag("old");
        showMsg1.showFlag02(generic3);




    }
}
